﻿namespace Digitalmes.Domain.Mes;

/// <summary>
/// SN 过程数据
/// </summary>
[SugarTable("prod_archive_data", "SN过程数据表")]
[SugarIndex("index_prod_archive_data_archiveid", nameof(ArchiveId), OrderByType.Asc)]
public class ProdArchiveData : EntityBaseId
{
    /// <summary>
    /// 产品数据存档信息 Id。
    /// </summary>
    [SugarColumn(ColumnDescription = "产品存档信息Id")]
    public long ArchiveId { get; set; }

    /// <summary>
    /// 存档主数据
    /// </summary>
    [NotNull]
    [Navigate(NavigateType.OneToOne, nameof(ArchiveId))]
    public ProdArchive? Archive { get; set; }

    /// <summary>
    /// 数据分类
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "数据分类", Length = 64)]
    public string? TypeCode { get; set; }

    /// <summary>
    /// 数据分类名称
    /// </summary>
    [NotNull]
    [SugarColumn(ColumnDescription = "数据分类名称", Length = 64)]
    public string? TypeName { get; set; }

    /// <summary>
    /// 数据集合
    /// </summary>
    /// <remarks>
    /// JSON 存储，MySQL 允许的最大尺寸为 max_allowed_packet，默认为 4194304byte，即 4MB，可以使用 "select@@max_allowed_packet;" 命令查看；
    /// SQL Server 2016+ 中数据类型为 nvarchar([len])，默认最大长度为 nvarchar(max)。
    /// </remarks>
    [NotNull]
    [SugarColumn(ColumnDescription = "数据集合", IsJson = true)]
    public List<ArchiveDataItem>? Data { get; set; }
}

